<?php
/**
 * @Author: gml
 * @Date:   2016-01-18 10:23:42
 * @Last Modified by:   gml
 * @Last Modified time: 2016-01-25 14:39:33
 */

/**
 * URL解密
 * @param  [type] $url [description]
 * @return [type]      [description]
 */
function urlsafe_decode($url) {
	$data = str_replace(array('-','_'),array('+','/'),$url);
	$mod4 = strlen($data) % 4;
	if ($mod4) {
		$data .= substr('====', $mod4);
	}
	return base64_decode($data);
 }

/**
 * URL加密
 * @param  [type] $url [description]
 * @return [type]      [description]
 */
function urlsafe_encoding($url){
   $data = base64_encode($url);
   $data = str_replace(array('+','/','='),array('-','_',''),$data);
   return $data;
}